package com.example.votemanage.mapper;

import com.example.votemanage.entity.VoteOption;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author liufangzhou
 * @since 2024-06-06
 */
public interface VoteOptionMapper extends BaseMapper<VoteOption> {

    @Select("SELECT * FROM  VOTE_OPTION WHERE vs_id=#{vsid}")
    @Results(id="option_Map",value = {
            @Result(property = "voId",column = "vo_id"),
            @Result(property = "items",column = "vo_id",many = @Many(select = "com.example.votemanage.mapper.VoteItemMapper.findItemByVoId")),
    })
    public List<VoteOption> findOptionByVsId(int vsid);
}
